﻿<UserControl x:Class="Black.Minecraft.Editor.Views.DataViews.InventoryDataView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:dv="clr-namespace:Black.Minecraft.Editor.Views.DataViews"
             xmlns:tk="http://schemas.xceed.com/wpf/xaml/toolkit"
             xmlns:vm="clr-namespace:Black.Minecraft.Editor.ViewModels"
             x:Name="root"
             Width="352"
             Height="332"
             Foreground="Black">

    <!--  Affichage de l'inventaire  -->

    <Grid>

        <!--  Image de fond  -->

        <Image Source="/Assets/Inventory.png" Stretch="None" />

        <!--  Zone des items  -->

        <Canvas>

            <!--  ***********  -->
            <!--  Zone Armure  -->
            <!--  ***********  -->

            <ContentControl Canvas.Left="16"
                            Canvas.Top="16"
                            Content="{Binding Head}" />

            <ContentControl Canvas.Left="16"
                            Canvas.Top="52"
                            Content="{Binding Chest}" />

            <ContentControl Canvas.Left="16"
                            Canvas.Top="87"
                            Content="{Binding Leg}" />

            <ContentControl Canvas.Left="16"
                            Canvas.Top="124"
                            Content="{Binding Feet}" />

            <!--  ***************  -->
            <!--  Zone inventaire  -->
            <!--  ***************  -->

            <!--  Ligne 1  -->

            <ContentControl Canvas.Left="16"
                            Canvas.Top="167"
                            Content="{Binding Bag11}" />

            <ContentControl Canvas.Left="52"
                            Canvas.Top="167"
                            Content="{Binding Bag12}" />

            <ContentControl Canvas.Left="88"
                            Canvas.Top="167"
                            Content="{Binding Bag13}" />

            <ContentControl Canvas.Left="124"
                            Canvas.Top="167"
                            Content="{Binding Bag14}" />

            <ContentControl Canvas.Left="160"
                            Canvas.Top="167"
                            Content="{Binding Bag15}" />

            <ContentControl Canvas.Left="196"
                            Canvas.Top="167"
                            Content="{Binding Bag16}" />

            <ContentControl Canvas.Left="232"
                            Canvas.Top="167"
                            Content="{Binding Bag17}" />

            <ContentControl Canvas.Left="268"
                            Canvas.Top="167"
                            Content="{Binding Bag18}" />

            <ContentControl Canvas.Left="304"
                            Canvas.Top="167"
                            Content="{Binding Bag19}" />

            <!--  Ligne 2  -->

            <ContentControl Canvas.Left="16"
                            Canvas.Top="204"
                            Content="{Binding Bag21}" />

            <ContentControl Canvas.Left="52"
                            Canvas.Top="204"
                            Content="{Binding Bag22}" />

            <ContentControl Canvas.Left="88"
                            Canvas.Top="204"
                            Content="{Binding Bag23}" />

            <ContentControl Canvas.Left="124"
                            Canvas.Top="204"
                            Content="{Binding Bag24}" />

            <ContentControl Canvas.Left="160"
                            Canvas.Top="204"
                            Content="{Binding Bag25}" />

            <ContentControl Canvas.Left="196"
                            Canvas.Top="204"
                            Content="{Binding Bag26}" />

            <ContentControl Canvas.Left="232"
                            Canvas.Top="204"
                            Content="{Binding Bag27}" />

            <ContentControl Canvas.Left="268"
                            Canvas.Top="204"
                            Content="{Binding Bag28}" />

            <ContentControl Canvas.Left="304"
                            Canvas.Top="204"
                            Content="{Binding Bag29}" />

            <!--  Ligne 3  -->

            <ContentControl Canvas.Left="16"
                            Canvas.Top="240"
                            Content="{Binding Bag31}" />

            <ContentControl Canvas.Left="52"
                            Canvas.Top="240"
                            Content="{Binding Bag32}" />

            <ContentControl Canvas.Left="88"
                            Canvas.Top="240"
                            Content="{Binding Bag33}" />

            <ContentControl Canvas.Left="124"
                            Canvas.Top="240"
                            Content="{Binding Bag34}" />

            <ContentControl Canvas.Left="160"
                            Canvas.Top="240"
                            Content="{Binding Bag35}" />

            <ContentControl Canvas.Left="196"
                            Canvas.Top="240"
                            Content="{Binding Bag36}" />

            <ContentControl Canvas.Left="232"
                            Canvas.Top="240"
                            Content="{Binding Bag37}" />

            <ContentControl Canvas.Left="268"
                            Canvas.Top="240"
                            Content="{Binding Bag38}" />

            <ContentControl Canvas.Left="304"
                            Canvas.Top="240"
                            Content="{Binding Bag39}" />

            <!--  *******************  -->
            <!--  Zone Barre d'action  -->
            <!--  *******************  -->

            <ContentControl Canvas.Left="16"
                            Canvas.Top="284"
                            Content="{Binding ActionBar1}" />

            <ContentControl Canvas.Left="52"
                            Canvas.Top="284"
                            Content="{Binding ActionBar2}" />

            <ContentControl Canvas.Left="88"
                            Canvas.Top="284"
                            Content="{Binding ActionBar3}" />

            <ContentControl Canvas.Left="124"
                            Canvas.Top="284"
                            Content="{Binding ActionBar4}" />

            <ContentControl Canvas.Left="160"
                            Canvas.Top="284"
                            Content="{Binding ActionBar5}" />

            <ContentControl Canvas.Left="196"
                            Canvas.Top="284"
                            Content="{Binding ActionBar6}" />

            <ContentControl Canvas.Left="232"
                            Canvas.Top="284"
                            Content="{Binding ActionBar7}" />

            <ContentControl Canvas.Left="268"
                            Canvas.Top="284"
                            Content="{Binding ActionBar8}" />

            <ContentControl Canvas.Left="304"
                            Canvas.Top="284"
                            Content="{Binding ActionBar9}" />

        </Canvas>

        <!--  Zone de saisie  -->

        <Button Margin="58,128,0,0"
                HorizontalAlignment="Left"
                VerticalAlignment="Top"
                Command="{Binding ElementName=root,
                                  Path=DataContext.RepairAllCommand}">
            <Button.ToolTip>
                <TextBlock Text="Repair all your items" />
            </Button.ToolTip>
            <Image Width="24"
                   Height="24"
                   RenderTransformOrigin="0.542,-0.5"
                   Source="/Assets/RepairAll.png"
                   Stretch="None" />
        </Button>

        <TextBlock Margin="0,77,0,0"
                   HorizontalAlignment="Center"
                   VerticalAlignment="Top"
                   Text="Select an item."
                   Visibility="{Binding HaveSelection,
                                        Converter={StaticResource BoolToVisibilityConverter},
                                        ConverterParameter=invert}" />

        <Border Width="284"
                Height="144"
                Margin="51,12,0,0"
                HorizontalAlignment="Left"
                VerticalAlignment="Top"
                Padding="15,15,15,0"
                Visibility="{Binding HaveSelection,
                                     Converter={StaticResource BoolToVisibilityConverter}}">
            <Grid DataContext="{Binding Selection}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="30" />
                    <RowDefinition Height="30" />
                    <RowDefinition Height="30" />
                    <RowDefinition Height="30" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="75" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <TextBlock Grid.Row="0"
                           Grid.Column="0"
                           VerticalAlignment="Center"
                           Foreground="Black"
                           Text="Type :" />
                <ComboBox Grid.Row="0"
                          Grid.Column="1"
                          Margin="0,4,0,4"
                          VerticalAlignment="Center"
                          FontWeight="Normal"
                          ItemsSource="{Binding Source={x:Static vm:MainViewModel.Instance},
                                                Path=ItemsDefinitionSource}"
                          SelectedItem="{Binding Definition,
                                                 Mode=TwoWay}">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Margin="2,0,2,0" Orientation="Horizontal">
                                <Image Width="16"
                                       Height="16"
                                       Source="{Binding Image}"
                                       Stretch="Fill" />
                                <TextBlock Margin="6,0,2,0" Text="{Binding Name}" />
                            </StackPanel>
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>

                <TextBlock Grid.Row="1"
                           Grid.Column="0"
                           VerticalAlignment="Center"
                           Foreground="Black"
                           Text="Count :" />
                <tk:IntegerUpDown Grid.Row="1"
                                  Grid.Column="1"
                                  Margin="0,4,0,4"
                                  VerticalAlignment="Center"
                                  FontWeight="Normal"
                                  Maximum="{Binding Definition.MaxStack}"
                                  Minimum="1"
                                  TextAlignment="Left"
                                  Value="{Binding Count,
                                                  Mode=TwoWay}" />

                <TextBlock Grid.Row="2"
                           Grid.Column="0"
                           VerticalAlignment="Center"
                           Foreground="Black"
                           Text="Damage :"
                           Visibility="{Binding Definition.CanRepair,
                                                Converter={StaticResource BoolToVisibilityConverter}}" />
                <tk:IntegerUpDown Grid.Row="2"
                                  Grid.Column="1"
                                  Margin="0,4,0,4"
                                  VerticalAlignment="Center"
                                  FontWeight="Normal"
                                  Minimum="0"
                                  TextAlignment="Left"
                                  Visibility="{Binding Definition.CanRepair,
                                                       Converter={StaticResource BoolToVisibilityConverter}}"
                                  Value="{Binding Damage,
                                                  Mode=TwoWay}" />

                <StackPanel Grid.Row="3"
                            Grid.Column="1"
                            HorizontalAlignment="Right"
                            VerticalAlignment="Center"
                            Orientation="Horizontal">
                    <Button Command="{Binding ElementName=root,
                                              Path=DataContext.EnchantCommand}"
                            CommandParameter="{Binding Enchant}"
                            Visibility="{Binding Definition.CanEnchant,
                                                 Converter={StaticResource BoolToVisibilityConverter}}">
                        <Button.ToolTip>
                            <TextBlock Text="Manage enchant on this item" />
                        </Button.ToolTip>
                        <Image Width="24"
                               Height="24"
                               Source="/Assets/Enchant.png"
                               Stretch="Uniform" />
                    </Button>
                    <Button Margin="6,0,0,0"
                            Command="{Binding ElementName=root,
                                              Path=DataContext.RepairCommand}"
                            Visibility="{Binding Definition.CanRepair,
                                                 Converter={StaticResource BoolToVisibilityConverter}}">
                        <Button.ToolTip>
                            <TextBlock Text="Repair this item" />
                        </Button.ToolTip>
                        <Image Width="24"
                               Height="24"
                               Source="/Assets/Repair.png"
                               Stretch="None" />
                    </Button>
                    <Button Margin="6,0,0,0" Command="{Binding ElementName=root, Path=DataContext.UpStackCommand}">
                        <Button.ToolTip>
                            <TextBlock Text="Set to max stack" />
                        </Button.ToolTip>
                        <Image Width="24"
                               Height="24"
                               Source="/Assets/UpStack.png"
                               Stretch="None" />
                    </Button>
                    <Button Margin="6,0,0,0" Command="{Binding ElementName=root, Path=DataContext.DeleteCommand}">
                        <Button.ToolTip>
                            <TextBlock Text="Delete this item" />
                        </Button.ToolTip>
                        <Image Width="24"
                               Height="24"
                               Source="/Assets/Delete.png"
                               Stretch="None" />
                    </Button>
                </StackPanel>

            </Grid>
        </Border>
    </Grid>
</UserControl>
